package com.aube.interact.fighter;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.widget.TextView;

/**
 * Created by huyaonan on 16/11/22.
 */
public class GamePrizeTextView extends TextView {

    private LinearGradient mLinearGradient;

    public GamePrizeTextView(Context context) {
        this(context, null);
    }

    public GamePrizeTextView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public GamePrizeTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        int width = getWidth();
        int height = getHeight();

        if(mLinearGradient == null) {
            mLinearGradient = new LinearGradient(width / 2, 0, width, height, new int[]{Color.RED, Color.YELLOW}, null, Shader.TileMode.CLAMP);
            getPaint().setShader(mLinearGradient);
        }

        super.onDraw(canvas);
    }
}
